<?php
/**
 * Created by PhpStorm.
 * User: 刘凯龙
 * Date: 2018/9/3
 * Time: 10:37
 */
use yii\helpers\Html;
use yii\grid\GridView;
use \yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Banner';
$this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class = "wrapper wrapper-content animated fadeInRight">
    <div class = "row">
        <div class = "col-sm-12">
            <div class = "ibox float-e-margins">
                <div class = "ibox-title">
                    <a class = "btn btn-sm btn-success" href = "<?= Url::to( [
                        'create' ,
                    ] ) ?>"><i class = "fa fa-plus"></i>&nbsp;&nbsp;<span>添加图片</span></a>
                </div>
                <div class="img-box" style="position: fixed;z-index: 100;background: #232321;display: none;height:60%;width: 30%;">
                    <img src=""  style="height:100%;width: 100%;">
                </div>
                <div class = "ibox-content">
                    <div class = "table-responsive">
                        <?= GridView::widget( [
                            'dataProvider'  => $dataProvider ,
                            'filterModel'   => $searchModel ,
                            'layout'        => '{summary}{items}<div class="text-right tooltip-demo">{pager}</div>' ,
                            'rowOptions'    => [ 'class' => 'text-center' ] ,
                            'pager'         => [
                                'firstPageLabel' => "首页" ,
                                'prevPageLabel'  => '上一页' ,
                                'nextPageLabel'  => '下一页' ,
                                'lastPageLabel'  => '尾页' ,
                            ] ,
                            'columns'       => [
                                [
                                    'class' => 'yii\grid\SerialColumn',
                                    'headerOptions' => [ 'style'=>['width' => '60','color'=>'#337ab7']] ,
                                ] ,
                                [
                                    'label'         => '图片' ,
                                    'format'        => 'raw' ,
                                    'filter'        => FALSE ,
                                    'value'         => function ( $model ) {
                                        return Html::img( IMG_URL . $model->image , [
                                            'style' => 'width:65px;height:50px;' ,
                                        ] );
                                    } ,
                                    'headerOptions' => [ 'style'=>['width' => '60','color'=>'#337ab7']] ,
                                ] ,
                                'ctime' ,
                                'utime' ,
                                [
                                    'label'         => '状态' ,
                                    'format'        => 'raw' ,
                                    'filter'        => FALSE ,
                                    'value'         => function ( $model ) {
                                        if($model->is_display == 1){
                                            return '显示';
                                        }elseif ($model->is_display == 2){
                                            return '不显示';
                                        }
                                    } ,
                                    'headerOptions' => [ 'style'=>['width' => '60','color'=>'#337ab7']] ,
                                ] ,
                                [
                                    'header'        => '操作',
                                    'class'         => 'yii\grid\ActionColumn' ,
                                    'template'      => '{update}  {delete}' ,
                                    'headerOptions' => [ 'style'=>['width' => '60','color'=>'#337ab7']] ,
                                    'buttons'       => [
                                        'update' => function ( $url , $model , $key ) {
                                            return Html::a( '修改' , [
                                                'update' ,
                                                'id' => $model->id ,
                                            ] , [ 'class' => "btn btn-xs btn-success" ] );
                                        } ,
                                        'delete' => function ( $url , $model , $key ) {
                                            return Html::a( '删除' , [
                                                'delete' ,
                                                'id' => $model->id ,
                                            ] , [
                                                'class' => "btn btn-xs btn-danger" ,
                                                'data'  => [
                                                    'confirm' => '确定要刪除吗？' ,
                                                    'method'  => 'post' ,
                                                ] ,
                                            ] );
                                        } ,
                                    ] ,
                                ] ,
                            ] ,
                        ] ); ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="application/javascript" src="/js/public.js"></script>
<script type="application/javascript">
    imageMax();
</script>

